package com.ruoyi.web.controller.biz;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.biz.domain.query.BizBinningForeignQuery;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.biz.domain.BizBinningForeign;
import com.ruoyi.biz.service.IBizBinningForeignService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 国外分箱Controller
 * 
 * @author ruoyi
 * @date 2022-08-04
 */
@RestController
@RequestMapping("/biz/binning/foreign")
public class BizBinningForeignController extends BaseController
{
    @Autowired
    private IBizBinningForeignService bizBinningForeignService;

    /**
     * 查询国外分箱列表
     */
    //@PreAuthorize("@ss.hasPermi('system:foreign:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizBinningForeignQuery query)
    {
        startPage();
        List<BizBinningForeign> list = bizBinningForeignService.selectBizBinningForeignList(query);
        return getDataTable(list);
    }

    /**
     * 导出国外分箱列表
     */
    //@PreAuthorize("@ss.hasPermi('system:foreign:export')")
    @Log(title = "国外分箱", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizBinningForeignQuery query)
    {
        List<BizBinningForeign> list = bizBinningForeignService.selectBizBinningForeignList(query);
        ExcelUtil<BizBinningForeign> util = new ExcelUtil<BizBinningForeign>(BizBinningForeign.class);
        util.exportExcel(response, list, "国外分箱数据");
    }

    /**
     * 获取国外分箱详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:foreign:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(bizBinningForeignService.selectBizBinningForeignById(id));
    }

    /**
     * 新增国外分箱
     */
    //@PreAuthorize("@ss.hasPermi('system:foreign:add')")
    @Log(title = "国外分箱", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(BizBinningForeign bizBinningForeign)
    {
        return toAjax(bizBinningForeignService.insertBizBinningForeign(bizBinningForeign));
    }

    /**
     * 修改国外分箱
     */
    //@PreAuthorize("@ss.hasPermi('system:foreign:edit')")
    @Log(title = "国外分箱", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(BizBinningForeign bizBinningForeign)
    {
        return toAjax(bizBinningForeignService.updateBizBinningForeign(bizBinningForeign));
    }

    /**
     * 删除国外分箱
     */
    //@PreAuthorize("@ss.hasPermi('system:foreign:remove')")
    @Log(title = "国外分箱", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizBinningForeignService.deleteBizBinningForeignByIds(ids));
    }
}
